package test;

import java.io.IOException;
import java.net.MalformedURLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.crawler.Crawler;
import com.crawler.dto.Parameter;
import com.crawler.dto.ProcessingTime;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;

public class T {

    public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException, ParseException {
//        System.out.println(new XTY_Site().setParameter(new Parameter("2112310666711", "胡志鹏")).enterCodeManually()
//                .resultsOf());
        
        List<Parameter> list = new ArrayList<Parameter>();
        list.add(new Parameter("8112310666711", "胡志鹏","2015年4月"));
        list.add(new Parameter("1609563100225", "ZHOU/QING MS","2015年4月"));
//        list.add(new Parameter("8112310666713", "胡志鹏"));
//        list.add(new Parameter("8112310666714", "胡志鹏"));
//        list.add(new Parameter("8112310666715", "胡志鹏"));
        
        JSONArray array = JSONArray.parseArray("[{\"ticketNo\":\"7841670463093\",\"passengerName\":\"胡静\"},{\"ticketNo\":\"7841675418265\",\"passengerName\":\"马荣奎\"},{\"ticketNo\":\"9991670462436\",\"passengerName\":\"倪兰\"},{\"ticketNo\":\"9991670462437\",\"passengerName\":\"谢永春\"},{\"ticketNo\":\"0181670462284\",\"passengerName\":\"朱静芝\"},{\"ticketNo\":\"0181670462310\",\"passengerName\":\"卢志平\"},{\"ticketNo\":\"0182329889215\",\"passengerName\":\"温郎民\"},{\"ticketNo\":\"7811670461876\",\"passengerName\":\"徐荣亮\"},{\"ticketNo\":\"0182329889084\",\"passengerName\":\"李其敏\"},{\"ticketNo\":\"0182329889085\",\"passengerName\":\"李永媛\"},{\"ticketNo\":\"0182329888967\",\"passengerName\":\"易健\"},{\"ticketNo\":\"0182329888968\",\"passengerName\":\"朱超群\"},{\"ticketNo\":\"7841672578042\",\"passengerName\":\"车毅明\"},{\"ticketNo\":\"0182329888956\",\"passengerName\":\"王蔚\"},{\"ticketNo\":\"0181682070377\",\"passengerName\":\"赵小华\"},{\"ticketNo\":\"0182329888816\",\"passengerName\":\"WIRYANA/SIDHARTA\"},{\"ticketNo\":\"0182329888760\",\"passengerName\":\"黄冠志\"},{\"ticketNo\":\"0181672578041\",\"passengerName\":\"王斌\"},{\"ticketNo\":\"0182329888629\",\"passengerName\":\"黄浩\"},{\"ticketNo\":\"0182329888630\",\"passengerName\":\"梁艳\"},{\"ticketNo\":\"0182329888631\",\"passengerName\":\"王婷婷\"},{\"ticketNo\":\"0182329888632\",\"passengerName\":\"尹士天\"},{\"ticketNo\":\"0182329888623\",\"passengerName\":\"蔡显满\"},{\"ticketNo\":\"0182329888624\",\"passengerName\":\"朱小林\"},{\"ticketNo\":\"0182329888571\",\"passengerName\":\"程斌\"},{\"ticketNo\":\"0182329888572\",\"passengerName\":\"肖军\"},{\"ticketNo\":\"0182329888567\",\"passengerName\":\"翁洋洋\"},{\"ticketNo\":\"0182329888568\",\"passengerName\":\"翁志强\"},{\"ticketNo\":\"0182329888569\",\"passengerName\":\"朱迪\"},{\"ticketNo\":\"0182329888536\",\"passengerName\":\"何婷\"},{\"ticketNo\":\"7811670461057\",\"passengerName\":\"蒋晓育\"},{\"ticketNo\":\"0182329888487\",\"passengerName\":\"詹伟\"},{\"ticketNo\":\"0182329888478\",\"passengerName\":\"蔡松\"},{\"ticketNo\":\"0182329888479\",\"passengerName\":\"黄曼琳\"},{\"ticketNo\":\"9991670460799\",\"passengerName\":\"潘军\"},{\"ticketNo\":\"9991670460865\",\"passengerName\":\"王晓晶\"},{\"ticketNo\":\"0182329888451\",\"passengerName\":\"帅军\"},{\"ticketNo\":\"0182329888375\",\"passengerName\":\"徐峰\"},{\"ticketNo\":\"0182329888324\",\"passengerName\":\"孙镇东\"},{\"ticketNo\":\"9991670460670\",\"passengerName\":\"路华\"},{\"ticketNo\":\"9991670460671\",\"passengerName\":\"周崇华\"},{\"ticketNo\":\"0182329888252\",\"passengerName\":\"吴海涛\"},{\"ticketNo\":\"7848530312338\",\"passengerName\":\"张驰\"},{\"ticketNo\":\"0182329888219\",\"passengerName\":\"于梅\"},{\"ticketNo\":\"0181672578040\",\"passengerName\":\"姚遥\"},{\"ticketNo\":\"0182329888114\",\"passengerName\":\"李铁\"},{\"ticketNo\":\"0182329888104\",\"passengerName\":\"姜晓明\"},{\"ticketNo\":\"0182329888048\",\"passengerName\":\"陈雅萍\"},{\"ticketNo\":\"0182329888049\",\"passengerName\":\"言金祥\"},{\"ticketNo\":\"0182329887914\",\"passengerName\":\"吴孝军\"},{\"ticketNo\":\"0182329887897\",\"passengerName\":\"李长存\"},{\"ticketNo\":\"0182329887848\",\"passengerName\":\"刘波\"},{\"ticketNo\":\"0182329887841\",\"passengerName\":\"包琳琳\"},{\"ticketNo\":\"0182329887842\",\"passengerName\":\"陈菊林\"},{\"ticketNo\":\"0182329887815\",\"passengerName\":\"SANCHEZ/EMILIO\"},{\"ticketNo\":\"0182329887800\",\"passengerName\":\"李鹏飞\"},{\"ticketNo\":\"0182329887801\",\"passengerName\":\"王君亮\"},{\"ticketNo\":\"9991670459832\",\"passengerName\":\"毛铮\"},{\"ticketNo\":\"9991670459833\",\"passengerName\":\"王建华\"},{\"ticketNo\":\"9991670459834\",\"passengerName\":\"吴永忠\"},{\"ticketNo\":\"9991670459835\",\"passengerName\":\"徐绍辉\"},{\"ticketNo\":\"0182329887685\",\"passengerName\":\"刘晓莹\"},{\"ticketNo\":\"0182329887612\",\"passengerName\":\"耿诚\"},{\"ticketNo\":\"0182329887613\",\"passengerName\":\"唐黎明\"},{\"ticketNo\":\"9992390140466\",\"passengerName\":\"徐龙\"},{\"ticketNo\":\"0182329887572\",\"passengerName\":\"梁军\"},{\"ticketNo\":\"0182329887573\",\"passengerName\":\"唐崎轩\"},{\"ticketNo\":\"0182329887506\",\"passengerName\":\"谭寅珍\"},{\"ticketNo\":\"7818541238380\",\"passengerName\":\"张雅娴\"},{\"ticketNo\":\"0182329887441\",\"passengerName\":\"耿诚\"},{\"ticketNo\":\"0182329887442\",\"passengerName\":\"唐黎明\"},{\"ticketNo\":\"7818541237903\",\"passengerName\":\"韩秀会\"},{\"ticketNo\":\"9991670459588\",\"passengerName\":\"王晓晶\"},{\"ticketNo\":\"7811670459566\",\"passengerName\":\"符红\"},{\"ticketNo\":\"7811670459567\",\"passengerName\":\"王宇\"},{\"ticketNo\":\"7811670459568\",\"passengerName\":\"易静华\"},{\"ticketNo\":\"0182329887331\",\"passengerName\":\"袁蕾\"},{\"ticketNo\":\"0181672578039\",\"passengerName\":\"殷雷\"},{\"ticketNo\":\"0182329887285\",\"passengerName\":\"曹宙\"},{\"ticketNo\":\"9991670459397\",\"passengerName\":\"孟强\"},{\"ticketNo\":\"7841670459332\",\"passengerName\":\"陈生荣\"},{\"ticketNo\":\"7841670459333\",\"passengerName\":\"牛小翠\"},{\"ticketNo\":\"7841670459334\",\"passengerName\":\"张超\"},{\"ticketNo\":\"0182329887155\",\"passengerName\":\"朱林美\"},{\"ticketNo\":\"9991670459291\",\"passengerName\":\"白耀华\"},{\"ticketNo\":\"9991670459292\",\"passengerName\":\"潘军\"},{\"ticketNo\":\"9991670459293\",\"passengerName\":\"吴洪相\"},{\"ticketNo\":\"0182329887127\",\"passengerName\":\"李旭\"},{\"ticketNo\":\"0182329887113\",\"passengerName\":\"刘成镛\"},{\"ticketNo\":\"0182329887114\",\"passengerName\":\"钱惠兰\"},{\"ticketNo\":\"0182329887106\",\"passengerName\":\"朱林美\"},{\"ticketNo\":\"0182329887104\",\"passengerName\":\"方海容\"},{\"ticketNo\":\"0182329887065\",\"passengerName\":\"吴小燕\"},{\"ticketNo\":\"0182329887061\",\"passengerName\":\"李斌\"},{\"ticketNo\":\"0182329887048\",\"passengerName\":\"刘宣锋\"},{\"ticketNo\":\"7818541234300\",\"passengerName\":\"王洋\"},{\"ticketNo\":\"7818541234301\",\"passengerName\":\"杨千\"},{\"ticketNo\":\"7811672578038\",\"passengerName\":\"杨斌\"},{\"ticketNo\":\"0182329886903\",\"passengerName\":\"闫刚\"},{\"ticketNo\":\"0182329886883\",\"passengerName\":\"李竹青\"}]");
        
//        for (int i = 0;i< 10;i++) {
//            list.add(new Parameter(array.getJSONObject(i).getString("ticketNo"),array.getJSONObject(i).getString("passengerName"),"2015年4月"));
//        }
        
        
        
        //手动输入验证码
        System.out.println("-------enterCodeManuallyCrawler start-----------");
        List<Parameter> enterCodeManuallyCrawler = Crawler.getInstance().enterCodeManuallyCrawler(list);
        for (Parameter parameter : enterCodeManuallyCrawler) {
            System.out.println(parameter.toString());
            //状态码
            System.out.println(parameter.getState());
        }
        System.out.println("-------enterCodeManuallyCrawler  end -----------");
        
        
        //通过第三方的验证码识别api识别验证码 识别率高 但是需要一定的费用
//        System.out.println("-------enterCodeChargeCrawler start-----------");
//        List<Parameter> enterCodeChargeCrawler =Crawler.getInstance().enterCodeChargeCrawler(list);
//        for (Parameter parameter : enterCodeChargeCrawler) {
//            System.out.println(parameter.toString());
//        }
//        System.out.println("-------enterCodeChargeCrawler  end -----------");
        
        
    }

}
